﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;


namespace XZen.Cdn.Client
{
    [Serializable]
    [XmlRootAttribute("span", Namespace = "http://cdn.xzen.in/keyvalue")]
    public class span
    {
        [XmlAttribute]
        public string id { get; set; }
        [XmlAttribute]
        public string name { get; set; }
        [XmlAttribute]
        public string text { get; set; }
        [XmlElementAttribute]
        public string value { get; set; }
    }
    [Serializable]
    [XmlRootAttribute("div", Namespace = "")]
    [KnownType(typeof(span))]
    public class div : List<span>
    {
        public override string ToString()
        {
            XmlSerializer srz = new XmlSerializer(this.GetType());
            StringWriter sb = new StringWriter();
            srz.Serialize(new System.Xml.XmlTextWriter(sb), this);
            return sb.ToString();
        }
        public static div FromString(string xml)
        {
            if (string.IsNullOrEmpty(xml)) return new div();
            XmlSerializer srz = new XmlSerializer(typeof(div));
            return (div)srz.Deserialize( new StringReader(xml));
        }
    }
}